<?php
class Raids extends Zend_Db_Table_Abstract {
	
    protected $_rowClass = 'RaidRow';
	protected $_name = 'raids';
	protected $_dependentTables = array('Usersignups','RaidsDungeons','RaidRosterChanges','RaidKills','RaidDungeonChanges');
	protected $_referenceMap = array(
		'Users' 		=> 	array(
						'columns' 		=> array('raidleader'),
						'refTableClass' => 'Users',
						'refColumns' 	=> array('id')
						));

	/**
	 * Short hand for getting a raid by its id.
	 * 
	 * This function does mysql safe escaping on the raid id.
	 *
	 * @param 	int 			raid id
	 * @return 	RaidRow|null
	 */
	public static function getById($raidId)
	{	
		// Raid id must be numeric
		if (!is_numeric($raidId)) {
			return null;
		}
		
		// Create static self
		$table = new self();
		
		// Create a select for getting the raid
		$select = $table->select()->where("id = ?", $raidId);
		$raid = $table->fetchRow($select);
		
		// Return the raid or null
		if ($raid) {
			return $raid;
		} else {
			return null;
		}
	}
	
}

